<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use App\Models\EditorImages;
use Encore\Admin\Controllers\ModelForm;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;

class EditorImagesController extends Controller
{
    use ModelForm;

    /**
     * Index interface.
     *
     * @return Content
     */
    public function index()
    {
        return Admin::content(function (Content $content) {

            $content->header('图片');
            $content->description('管理');

            $content->body($this->grid());
        });
    }


    protected function grid()
    {
        return Admin::grid(EditorImages::class, function (Grid $grid) {
            $grid->model()->orderBy("id", "desc");
            $grid->id('ID');
            $grid->user()->name();
            $grid->caption()->limit(20);

            $grid->column('img_name')->display(function ($v) {
                return $v . '!200x135';
            });

            $grid->created_at();

            $grid->setView('admin.grid.card');

            $grid->disableBatchDeletion();
            $grid->disableExport();
            $grid->disableCreation();

        });
    }
}
